// @license
// Copyright 2024 The Model Explorer Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ==============================================================================

.container {
  padding-top: 12px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  height: 100%;

  .index-number {
    width: 16px;
    height: 16px;
    border-radius: 8px;
    box-sizing: border-box;
    border: 1px solid var(--me-outline-color);
    background-color: var(--me-surface-container-high-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .node-filter {
    margin-bottom: 4px;
    position: relative;

    input {
      width: 100%;
      border: 1px solid var(--me-outline-variant-color);
      padding: 3px 4px 3px 19px;
      border-radius: 4px;
      box-sizing: border-box;
    }

    mat-icon {
      font-size: 12px;
      width: 12px;
      height: 12px;
      color: var(--me-on-surface-variant-color);

      &.filter {
        position: absolute;
        top: 6px;
        left: 3px;
      }
    }

    .clear-container {
      position: absolute;
      top: 6px;
      right: 3px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;

      &:hover mat-icon {
        color: var(--me-on-surface-variant-color);
      }
    }
  }

  .icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    opacity: 0.3;
    cursor: pointer;

    &.selected {
      opacity: 1;
      cursor: default;

      mat-icon {
        color: var(--me-warning-text-color);
      }
    }

    &.hide {
      visibility: hidden;
    }

    &.action {
      opacity: 0.7;
      margin-left: 4px;

      &:hover {
        opacity: 1;
      }
    }

    &.visibility {
      margin-left: 4px;
    }

    mat-icon {
      font-size: 16px;
      width: 16px;
      height: 16px;
      line-height: 16px;
      color: var(--me-on-surface-variant-color);
    }
  }

  .index-container {
    .index-row {
      display: flex;
      align-items: center;
      overflow: hidden;
      padding: 2px 8px;
      cursor: pointer;

      &.selected {
        background-color: var(--me-warning-container-color);
      }

      .index-number-container {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 6px;
      }

      .run-name {
        flex-grow: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .action-icons-container {
        display: flex;
        align-items: center;
        flex-shrink: 0;
      }
    }
  }

  select {
    width: 100%;
  }

  .running {
    display: flex;
    align-items: center;
    margin-top: 16px;

    mat-spinner {
      margin-right: 4px;
    }

    .label {
      color: var(--me-on-surface-variant-color);
    }
  }

  .error {
    width: 16px;
    height: 16px;

    mat-icon {
      font-size: 16px;
      height: 16px;
      width: 16px;
      color: var(--me-error-text-color);
    }
  }

  .table-container {
    width: 100%;
    box-sizing: border-box;
    padding: 8px;
    margin-top: 2px;
    display: flex;
    flex-direction: column;
    transition: max-height 150ms ease-out;
    overflow-y: clip;

    &.collapsed {
      /* stylelint-disable-next-line declaration-no-important -- override element style */
      max-height: 30px !important;
    }

    .table-title-container {
      display: flex;
      align-items: center;
      justify-content: space-between;
      line-height: 22px;

      .title-label-container {
        display: flex;
        align-items: center;
        cursor: pointer;
        user-select: none;
        line-height: 15px;

        mat-icon {
          margin-left: -4px;
        }
      }
    }

    paginator {
      align-self: flex-end;
    }
  }

  table {
    border: 1px solid var(--me-outline-variant-color);
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
    user-select: none;
    background-color: var(--me-surface-container-low-color);
    overflow: hidden;

    thead {
      height: 24px;
      background-color: var(--me-surface-container-high-color);
    }

    tbody {
      font-family: Arial, Helvetica, sans-serif;
    }

    tr:hover {
      outline: 1px solid var(--me-outline-color);
    }

    td,
    th {
      padding: 1px 4px;
      text-align: left;

      &.node-label {
        border-left: 1px solid var(--me-outline-hairline-color);
      }

      &.value-col {
        border-left: 1px solid var(--me-outline-hairline-color);
        max-width: 80px;
        text-overflow: ellipsis;
        overflow: hidden;
      }
    }

    .header-content {
      height: 100%;
      display: flex;
      align-items: center;

      mat-icon.sort {
        font-size: 12px;
        width: 12px;
        height: 12px;
        color: var(--me-on-surface-variant-color);
        margin-left: 4px;
        flex-shrink: 0;
      }

      .stat-label {
        margin-left: 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;

        &.multi-line {
          white-space: pre;
        }
      }
    }

    th {
      cursor: pointer;
    }

    td.node-label {
      cursor: pointer;

      &:hover {
        text-decoration: underline dotted var(--me-primary-color);
      }
    }

    td.input {
      color: var(--me-incoming-edge-color);
      font-weight: 500;
    }

    td.output {
      color: var(--me-outgoing-edge-color);
      font-weight: 500;
    }
  }

  .hidden {
    display: none;
  }
}
